<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>#{msg.app_name}</title>
    <h:outputStylesheet name="styleDefault.css" library="css" />
</h:head>

<h:body>
	<h:form>
		<div align="center">
			<br /><br />
			<h:panelGrid columns="2">
				<h:commandLink action="#{intMB.mudarIdioma}">
					<h:graphicImage url="${pageContext.request.contextPath}/resources/img/br.jpg" />
					<f:setPropertyActionListener target="#{intMB.linguagem}" value="pt" />
					<f:setPropertyActionListener target="#{intMB.pais}" value="BR" />
					<f:ajax execute="@this" render="@form" />
				</h:commandLink>
				<h:commandLink action="#{intMB.mudarIdioma}">
					<h:graphicImage url="${pageContext.request.contextPath}/resources/img/us.jpg" />
					<f:setPropertyActionListener target="#{intMB.linguagem}" value="en" />
					<f:setPropertyActionListener target="#{intMB.pais}" value="US" />
					<f:ajax execute="@this" render="@form" />
				</h:commandLink>
			</h:panelGrid>
			<h:panelGrid id="grid" columns="3">
				<p:outputLabel for="inputLogin" value="#{msg.login}: " />
				<p:inputText value="#{autenticacaoMB.login}" id="inputLogin" required="true" requiredMessage="#{msg.loginObrigatorio}"/>
				<p:message for="inputLogin" />
	
				<p:outputLabel for="inputSenha" value="#{msg.senha}: " />
				<p:password value="#{autenticacaoMB.senha}" id="inputSenha" 
					required="true" requiredMessage="#{msg.senhaObrigatoria}" />
				<p:message for="inputSenha" />
	
				<p:commandButton id="entrar" value="Entrar" action="#{autenticacaoMB.logar}" update="grid" />
				<p:commandButton value="#{msg.adicionar}" update=":formAdicionarUsuario:usuarioAdicionar" oncomplete="PF('adicionarDialog').show()">
					<f:ajax execute="@this" />
				</p:commandButton>			
			</h:panelGrid>
		</div>	
	</h:form>
	<h:form id="formAdicionarUsuario">
		<p:dialog header="#{msg.adicionar}" widgetVar="adicionarDialog" modal="true">
			<p:outputPanel id="usuarioAdicionar">
				<h:panelGrid id="grid" columns="3">

					<p:outputLabel for="inputLogin" value="#{msg.login}:" />
					<p:inputText value="#{usuarioMB.usuario.login}" id="inputLogin" required="true" requiredMessage="#{msg.loginObrigatorio}" />
					<p:message for="inputLogin" /> 

					<p:outputLabel for="inputNome" value="#{msg.nome}:" />
					<p:inputText value="#{usuarioMB.usuario.nome}" id="inputNome" required="true" requiredMessage="#{msg.nomeObrigatorio}" />
					<p:message for="inputNome" /> 

					<p:outputLabel for="inputSenha" value="#{msg.senha}:" />
					<p:inputText value="#{usuarioMB.usuario.senha}" id="inputSenha" required="true" requiredMessage="#{msg.senhaObrigatoria}" />
					<p:message for="inputSenha" /> 

				</h:panelGrid>

				<p:commandButton value="#{msg.salvar}" id="salvar" update="grid"
					action="#{usuarioMB.salvar}"/>
			</p:outputPanel>
		</p:dialog>
	</h:form>	
</h:body>
</html>